<script type="text/javascript">
	function onClickDictionary(rowIndex, rowData) {
		printLog(rowIndex);
		//先取得 datagrid 的查询参数  
		var params = $('#dictionary_valuelist').datagrid('options').queryParams;
		params['dictionaryId'] = rowData.id;
		//设置好查询参数 reload 一下就可以了 
		$('#dictionary_valuelist').datagrid('reload');  
	}
	
	//表格查询  
	function reloadDictionary() {
		dictionary_dictionarylist.datagrid('reload'); //设置好查询参数 reload 一下就可以了  
		dictionary_dictionarylist.datagrid('unselectAll');
		dictionary_dictionarylist.datagrid('uncheckAll');
		onClickDictionary(0,{rowData:''});
	}

	function addDictionaryCode(){
		createFromWindowOptions({
			title:"新增信息",
			maximizable:true,
			href:"dictionaryCode.do?editDictionary",
			callback:function(data) {
				printLog(data);
				saveDictionaryCodeValueInfo();
			},
			enableSaveButton:true
		});
	}
	
	function editDictionaryCode() {
		var rows = dictionary_dictionarylist.datagrid('getChecked');
		printLog(rows);
		if (rows&&rows.length>0) {
			if(rows.length>1) {
				showMsg('请选择一条操作记录.');
				return;
			}
			createFromWindowOptions({
				title:"编辑信息",
				maximizable:true,
				href:"dictionaryCode.do?editDictionary&dictionaryId="+ rows[0].id,
				callback:function(data) {
					printLog(data);
					saveDictionaryCodeValueInfo();
				},
				enableSaveButton:true
			});
		} else {
			showMsg('请选择操作记录.');
		}
	}
	//添加字典值项
// 	function addDictionaryCodeValue() {
// 		var rows = dictionary_dictionarylist.datagrid('getChecked');
// 		printLog(rows);
// 		if (rows&&rows.length>0) {
// 			if(rows.length>1) {
// 				showMsg('请选择一条操作记录.');
// 				return;
// 			}
// 			createFromAutoSubmitWindow({
// 				title:"编辑字典值信息",
// 				maximizable:false,
// 				width:800,
// 				height:500,
// 				href:"dictionaryCode.do?editDictionary&dictionaryId="+ rows[0].id,
// 				submitUrl:"dictionaryCode.do?saveDictionary",
// 				callback:function(data) {
// 					reloadDictionary();
// 				},
// 				enableSaveButton:true
// 			});
// 		} else {
// 			showMsg('请选择操作记录.');
// 		}
// 	}
	
	function deleteDictionaryCode() {
		var rows = dictionary_dictionarylist.datagrid('getChecked');
		printLog(rows);
	    if (rows&&rows.length>0){
	        $.messager.confirm('询问','你确认要删除记录吗?',function(r){
	            if (r){
	            	var ids = "";
	            	for(var i=0; i<rows.length; i++){
	            		ids += rows[i].id+",";
	            	}
	                $.post('dictionaryCode.do?deleteDictionaryCodeItems',{ids:ids},function(result){
	                    if (result.success){
	                    	reloadDictionary();
	                    }
	                    showMsg(result.msg);
	                },'json');
	            }
	        });
	    }else {
	    	showMsg("请选择操作记录.");
	    }
	}
</script>
<div class="easyui-layout" data-options="fit:true">
    <div data-options="region: 'west', title: '字典列表',border:false, split: true," style="width: 580px;">
		<@eu.datagrid id="dictionary_dictionarylist" idField="id" toolbar="#dictionary_dictionarylist_toolbar"
		url="dictionaryCode.do?loadByCondition"
		item="com.xdtech.sys.vo.DictionaryCodeItem" 
		onClickRow="onClickDictionary(rowIndex, rowData)" />
		<div id="dictionary_dictionarylist_toolbar">
			<@eu.linkbutton showName="新增" shiro="sys:dictionaryCode:add" iconCls="icon-add" onclick="addDictionaryCode()"/>
			<@eu.linkbutton showName="编辑" shiro="sys:dictionaryCode:edit" iconCls="icon-edit" onclick="editDictionaryCode()"/>
			<@eu.linkbutton showName="删除" shiro="sys:dictionaryCode:delete" iconCls="icon-remove" onclick="deleteDictionaryCode()"/>
			<@eu.linkbutton showName="刷新" shiro="sys:dictionaryCode:refresh" iconCls="icon-reload" onclick="reloadDictionary()"/>
		</div>
	</div>
 

	<div data-options="region:'center',border:false">
		<@eu.datagrid id="dictionary_valuelist" title="字典值" 
			 url="codeValue.do?loadByCondition" rownumbers="false" pagination="false"
			 item="com.xdtech.sys.vo.CodeValueItem"/>
	</div>
</div>